import { queryMyPositionCodeList } from '@/apis/user'
const user = {
  state: {
    userInfo: null
  },
  mutations: {
    updateUserInfo(state, data) {
      state.userInfo = data
    },
    SETPOSITIONCODE(state, data) {
      const user = state.userInfo || {}
      state.userInfo = { ...user, positionCodes: data || [] }
    }
  },
  actions: {
    getMyPositionCode({ commit, state }) {
      return new Promise((resolve, reject) => {
        queryMyPositionCodeList().then(data => {
          commit('SETPOSITIONCODE', data)
          resolve(data)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
export default user

